/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tests;

import clip.model.ClipboardSnapshot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author admin
 */
public class tobtest {

    
    public static void main(String[] args) {
        Clipboard systemClip = Toolkit.getDefaultToolkit().getSystemClipboard();
        //erstellen
        ClipboardSnapshot cs = new ClipboardSnapshot(systemClip);
        
        //in datei speichern (--> statt fileoutputstream halt der netzstream):
        ObjectOutputStream oos;
        try {
            oos = new ObjectOutputStream(new FileOutputStream("snapshot.801"));
            oos.writeObject(cs);
            oos.close();
        } catch (Exception ex) {
            Logger.getLogger(tobtest.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        //clipboard leermachen
        //systemClip.setContents(new StringSelection("ich will pizza"),null);
        
        //laden
//        ClipboardSnapshot geladenerCS;
//        try {
//            geladenerCS = (ClipboardSnapshot) new ObjectInputStream(new FileInputStream("snapshot.800")).readObject();
//            systemClip.setContents(geladenerCS, null);
//        } catch (Exception ex) {
//            Logger.getLogger(tobtest.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        try {
//            Thread.sleep(10000);
//        } catch (InterruptedException ex) {
//            Logger.getLogger(tobtest.class.getName()).log(Level.SEVERE, null, ex);
//        }
    }
    
    
//    
//    @Deprecated
//    public void friedhof(String[] args) {
//        Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
//        Transferable transferData = systemClipboard.getContents(null);
//
////        for (int i = 0; i < transferData.getTransferDataFlavors().length; i++) {
////            DataFlavor df = transferData.getTransferDataFlavors()[i];
////            L.d("flavor "+i+" :",df.getPrimaryType(),df.getDefaultRepresentationClassAsString(),df.getHumanPresentableName(),df.getMimeType(),df.getTextPlainUnicodeFlavor(),df.);
////        }
////        L.d(transferData.toString());
////        
////        DataFlavor dataFlavor[] = transferData.getTransferDataFlavors();
////        Object content;
////        try {
////            content = transferData.getTransferData(dataFlavor[0]);
////            L.d(content);
////        } catch (UnsupportedFlavorException ex) {
////            Logger.getLogger(tobtest.class.getName()).log(Level.SEVERE, null, ex);
////        } catch (IOException ex) {
////            Logger.getLogger(tobtest.class.getName()).log(Level.SEVERE, null, ex);
////        }
////        
//    }
//    
//    void write() {
//        Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
//        Transferable transferData = systemClipboard.getContents(null);
//
//        DataFlavor df = transferData.getTransferDataFlavors()[0];
//        try {
//            df.writeExternal(new ObjectOutputStream(new FileOutputStream("test.800")));
//        } catch (IOException ex) {
//            Logger.getLogger(tobtest.class.getName()).log(Level.SEVERE, null, ex);
//        }
//    }
//
//    void read() {
//        Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
//        
//    }
//    
}
